
package org.hw.entity;

import java.io.Serializable;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * 
 * @TableName unit
 * @description 单位管理 用于数据隔离
 */
@Data
@TableName("unit")
@ApiModel
public class Unit implements Serializable {
    
	/**
	 * 编号
	 */
	@TableField(fill = FieldFill.INSERT)
	@ApiModelProperty("编号")
	private String unitId;
					
    /**
     * 层级
	 * 
     */
    @ApiModelProperty("层级")
    private Integer level;
				
    /**
     * 排序
	 * 
     */
    @ApiModelProperty("排序")
    private Integer sort;
				
    /**
     * 父单位
	 * 
     */
    @ApiModelProperty("父单位")
    private String parentUnitId;
				
    /**
     * 单位名称
	 * 
     */
    @ApiModelProperty("单位名称")
    private String name;
				
    /**
     * LOGO
	 * 
     */
    @ApiModelProperty("LOGO")
    private String image;
				
    /**
     * 授权码
	 * 
     */
    @ApiModelProperty("授权码")
    private String authorzation;
				
	/**
	 * ID
	 */
	@TableId(type = IdType.ASSIGN_ID)
	@ApiModelProperty("ID")
	@JsonSerialize(using = ToStringSerializer.class)
	private Long id;
			
	/**
	 * 创建时间
	 */
	@TableField(fill = FieldFill.INSERT)
	@ApiModelProperty("创建时间")
	@JsonSerialize(using = ToStringSerializer.class)
	private Long createTime;
				  
	/**
	 * 创建时间
	 */
	@TableField(fill = FieldFill.INSERT)
	@ApiModelProperty("创建时间")
	private String createTimeString;
					
	/**
	 * 更新时间
	 */
	@TableField(fill = FieldFill.UPDATE)
	@ApiModelProperty("更新时间")
	@JsonSerialize(using = ToStringSerializer.class)
	private Long updateTime;
					
	/**
	 * 更新时间
	 */
	@TableField(fill = FieldFill.UPDATE)
	@ApiModelProperty("更新时间")
	private String updateTimeString;
					
	/**
	 * 逻辑删除控制
	 */
	@ApiModelProperty("逻辑删除控制")
	@TableLogic
	private Integer state;
			  
	
	/**
	 * 设置编号
	 */
	public void setUnitId(String unitId){
		this.unitId = unitId;
	}

	/**
	 * 获取编号
	 */
	public String getUnitId(){
		return this.unitId;
	}
		
	/**
	 * 设置层级
	 */
	public void setLevel(Integer level){
		this.level = level;
	}

	/**
	 * 获取层级
	 */
	public Integer getLevel(){
		return this.level;
	}
		
	/**
	 * 设置排序
	 */
	public void setSort(Integer sort){
		this.sort = sort;
	}

	/**
	 * 获取排序
	 */
	public Integer getSort(){
		return this.sort;
	}
		
	/**
	 * 设置父单位
	 */
	public void setParentUnitId(String parentUnitId){
		this.parentUnitId = parentUnitId;
	}

	/**
	 * 获取父单位
	 */
	public String getParentUnitId(){
		return this.parentUnitId;
	}
		
	/**
	 * 设置单位名称
	 */
	public void setName(String name){
		this.name = name;
	}

	/**
	 * 获取单位名称
	 */
	public String getName(){
		return this.name;
	}
		
	/**
	 * 设置LOGO
	 */
	public void setImage(String image){
		this.image = image;
	}

	/**
	 * 获取LOGO
	 */
	public String getImage(){
		return this.image;
	}
		
	/**
	 * 设置授权码
	 */
	public void setAuthorzation(String authorzation){
		this.authorzation = authorzation;
	}

	/**
	 * 获取授权码
	 */
	public String getAuthorzation(){
		return this.authorzation;
	}
		
	/**
	 * 设置ID
	 */
	public void setId(Long id){
		this.id = id;
	}

	/**
	 * 获取ID
	 */
	public Long getId(){
		return this.id;
	}
		
	/**
	 * 设置创建时间
	 */
	public void setCreateTime(Long createTime){
		this.createTime = createTime;
	}

	/**
	 * 获取创建时间
	 */
	public Long getCreateTime(){
		return this.createTime;
	}
		
	/**
	 * 设置创建时间
	 */
	public void setCreateTimeString(String createTimeString){
		this.createTimeString = createTimeString;
	}

	/**
	 * 获取创建时间
	 */
	public String getCreateTimeString(){
		return this.createTimeString;
	}
		
	/**
	 * 设置更新时间
	 */
	public void setUpdateTime(Long updateTime){
		this.updateTime = updateTime;
	}

	/**
	 * 获取更新时间
	 */
	public Long getUpdateTime(){
		return this.updateTime;
	}
		
	/**
	 * 设置更新时间
	 */
	public void setUpdateTimeString(String updateTimeString){
		this.updateTimeString = updateTimeString;
	}

	/**
	 * 获取更新时间
	 */
	public String getUpdateTimeString(){
		return this.updateTimeString;
	}
		
	/**
	 * 设置逻辑删除控制
	 */
	public void setState(Integer state){
		this.state = state;
	}

	/**
	 * 获取逻辑删除控制
	 */
	public Integer getState(){
		return this.state;
	}
		
	public String stringify(){
		String rc = "{\"level\":\"" + this.getLevel() + "\",\"sort\":\"" + this.getSort() + "\",\"parentUnitId\":\"" + this.getParentUnitId() + "\",\"name\":\"" + this.getName() + "\",\"image\":\"" + this.getImage() + "\",\"authorzation\":\"" + this.getAuthorzation() + "\",\"id\":\"" + this.getId() + "\",\"createTime\":\"" + this.getCreateTime() + "\",\"createTimeString\":\"" + this.getCreateTimeString() + "\",\"updateTime\":\"" + this.getUpdateTime() + "\",\"updateTimeString\":\"" + this.getUpdateTimeString() + "\",\"state\":\"" + this.getState() + "\",\"unitId\":\"" + this.getUnitId() + "\"}";
		rc = rc.replaceAll("\"null\"","null").replaceAll("\"([0-9]+)\"","$1");
        return rc;
	}

	public static Unit JSONparse(String jsonString) throws JsonProcessingException {
        if(jsonString == null) return null;
		try {
            ObjectMapper objectMapper = new ObjectMapper();
            return objectMapper.readValue(jsonString,Unit.class);
        }catch (JsonProcessingException e){
            return null;
        }
    }
}
    